<?php

function returnSuccess($msg = "成功",$data = [],$code = 200){
    $result = [
        "code" => $code,
        "msg" => $msg,
        "data" => $data,
    ];

    return json_encode($result);
}

function returnError($msg = "失败",$data = [],$code = -101){
    $result = [
        "code" => $code,
        "msg" => $msg,
        "data" => $data,
    ];

    return json_encode($result);
}

function p($data){
    echo "<pre>";
    var_dump($data);
    echo "<pre>";
    exit;
}

/**
 * 生成编号
 * @param string $str
 * @return string
 */
function goodsSn($str = "")
{
    return $str . date('YmdHis').rand(1000,9999);
}
